<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>监听器监听年龄</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.js"></script>

</head>
<body>

    <div id="app">
        请输入年龄: <input type="text" v-model="age">
        结果：<p>{{info}}</p>

    </div>
    <script>
        new Vue({
            el:'#app',
            data() {
                return {
                    age:0,
                    info:''
                }
            },
            methods: {
                checkAge(){
                    debugger
                    if(this.age > 18){
                        this.info = '成年人'
                    }else{
                        this.info = '未成年'
                    }
                }
            },
            watch:{
                age: 'checkAge'
            }
        })
    </script>
</body>
</html>